/**
 * 
 */
package com.wegax.finprod;

import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;

/**
 * @author wegax
 * 
 */
public class FinancialProductForms extends Application implements MainViewChanger {

	private Panel mainPanel;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.vaadin.Application#init()
	 */
	@Override
	public void init() {
		initLocale();
		initView();
	}

	private void initView() {
		mainPanel = new Panel();
		mainPanel.setWidth("54em");
		setMainWindow(new Window("", mainPanel));
		changeView(new ApplicationFormsSelectionView(this));
	}

	private void initLocale() {
		setLocale(((WebApplicationContext) getContext()).getBrowser().getLocale());
	}

	@Override
	public void changeView(TitledForm titledForm) {
		getMainWindow().setCaption(titledForm.getTitle());
		mainPanel.setCaption(titledForm.getTitle());
		mainPanel.removeAllComponents();
		mainPanel.addComponent(titledForm.getComponentContainer());
	}
}
